on init {Created by Alex Vincent} {Allows you to time all shorts, slow/medium/fast legato into the same offset} {You should offset your MIDI track by -300ms by default, or whatever you set the Slow Legato to} {Optionally, control shorts with CC dynamics, and play trills with a single key} {TODO:} {Investigate nonsense delay values} {Show keyswitch values as notes not numbers} {Cinematic Studio Brass} {Make help tab the default} {Consider renaming variables for tremolo, harmonics, measuredTremolo and pizzicato} declare @scriptTitle @scriptTitle := "AVO - CSS Control Panel 1.8" set_script_title(@scriptTitle) declare @disclaimer @disclaimer := @scriptTitle & " | Created by Alex Vincent. Check alexjevincent.co.uk/css-control-panel for more information" message ("") declare $debug $debug := 0 declare $i $i := 0 declare $keyswitchLow {Lowest Keyswitch} declare $keyswitchHigh {Highest Keyswitch} declare $keyswitchCC {CSS Keyswitch CC (user controlled)} declare $delayCC {CC for disabling the delay} declare $dynamicCC {CC for controlling dynamics} declare $delayMode {For whether the delay is CC controlled or always on} declare $legatoMode {Whether legato mode is on or not} declare $shortsMode {Whether we want to control shorts by dynamicCC} declare $trillsMode {Whether we want one note trills} declare $delayKeyswitching {If true, also delays keyswitches and keyswitch CC} declare $delayControllers {If true, also delays controllers like dynamicsCC} declare $autoRebow {Spike CC64 if this is on} declare $inputChannel {Channel we are going to edit on} declare $lastDelay {Last delay length triggered} declare $lastDynamicCCValue {Last dynamics CC value} declare $lastDelayCCValue {Last delay CC value} declare $keyswitchNote {Note of incoming keyswitch} declare $keyswitchVelocity {Velocty of incoming keyswitch} declare $legatoKeyswitchNote {Note of incoming legato keyswitch} declare $legatoKeyswitchVelocity {Velocity of incoming legato keyswitch} declare $keyswitchCCValue {Value of keyswitch CC} {CSS play mode} {0 is any generic note, 1 is shorts, 2 is minor trills, 3 is major trills, 4 is longs or standard legato, 5 is longs or advanced legato} declare $noteMode {Instrument mode} {0 is CSS or CSSS, 1 is CSB, 2 is CSW} declare $instrumentMode declare $shortsDelay {Speed of shorts like staccato} declare $slowLegatoDelay {Speed of portamento used by both modes and slow legato transitions used by advanced legato} declare $mediumLegatoDelay {Speed of medium legato transition, the default mode for standard legato} declare $fastLegatoDelay {Speed of fast legato transition and sustains like trills, marcato, harmonics etc.} declare $firstLegatoDelay {Speed of the first legato note} {Increments up every time a legato note is played, then down as legato notes note off} {This allows the script to set a delay value for the first note in the phrase} declare $legatoNoteCount {For remembering the last legato note pitch} declare $legatoNotePitch {Keyswitches} declare $sustainKeyswitch declare $staccatoKeyswitch declare $tremoloKeyswitch declare $harmonicsKeyswitch declare $trillsKeyswitch declare $measuredTremoloKeyswitch declare $marcatoKeyswitch declare $pizzicatoKeyswitch declare $legatoKeyswitch declare $conSordinoKeyswitch declare %keyswitchArray[10] declare %keyswitchSortArray[10] {Default values that are overridden by persistent values} $keyswitchCC := 58 $delayCC := 13 $dynamicCC := 1 $inputChannel := 0 declare $shortsDelay_General {Speed of shorts like staccato} declare $slowLegatoDelay_Strings {Speed of portamento used by both modes and slow legato transitions used by advanced legato} declare $slowLegatoDelay_Winds {Speed of slow legato transitions used by advanced legato} declare $mediumLegatoDelay_Strings {Speed of medium legato transition, the default mode for standard legato} declare $mediumLegatoDelay_Brass {Speed of medium legato transition, the default mode for standard legato} declare $mediumLegatoDelay_Trumpets {Speed of medium legato transition, the default mode for standard legato} declare $mediumLegatoDelay_Winds {Speed of medium legato transition} declare $fastLegatoDelay_General {Speed of fast legato transition and sustains like trills, marcato, harmonics etc.} declare $fastLegatoDelay_Winds {Speed of fast legato transition and sustains like trills, marcato, harmonics etc.} declare $firstLegatoDelay_General {Speed of the first legato note} declare $firstLegatoDelay_Winds {Speed of the first legato note} $shortsDelay_General := 60 $slowLegatoDelay_Strings := 330 $slowLegatoDelay_Winds := 220 $mediumLegatoDelay_Strings := 250 $mediumLegatoDelay_Brass := 230 $mediumLegatoDelay_Trumpets := 180 $mediumLegatoDelay_Winds := 130 $fastLegatoDelay_General := 100 $fastLegatoDelay_Winds := 90 $firstLegatoDelay_General := 100 $firstLegatoDelay_Winds := 90 $shortsDelay := $shortsDelay_General $slowLegatoDelay := $slowLegatoDelay_Strings $mediumLegatoDelay := $mediumLegatoDelay_Strings $fastLegatoDelay := $fastLegatoDelay_General $firstLegatoDelay := $firstLegatoDelay_General $noteMode := 0 $instrumentMode := 0 $delayMode := 0 $legatoMode := 0 $shortsMode := 0 $trillsMode := 0 $delayKeyswitching := 0 $delayControllers := 1 {Note this is by default on, as I think it makes more sense to the user} $autoRebow := 0 $lastDelay := 0 $lastDelayCCValue := 0 $lastDynamicCCValue := 0 $legatoNoteCount := 0 $keyswitchNote := 0 $keyswitchVelocity := 0 $sustainKeyswitch := 24 $staccatoKeyswitch := 29 $tremoloKeyswitch := 25 $harmonicsKeyswitch := 28 $trillsKeyswitch := 27 $measuredTremoloKeyswitch := 26 $marcatoKeyswitch := 30 $pizzicatoKeyswitch := 31 $conSordinoKeyswitch := 35 $legatoKeyswitch := 34 {Make user populated variables persistent} make_persistent($keyswitchLow) make_persistent($keyswitchHigh) make_persistent($keyswitchCC) make_persistent($delayCC) make_persistent($dynamicCC) make_persistent($inputChannel) make_persistent($shortsMode) make_persistent($trillsMode) make_persistent($delayKeyswitching) make_persistent($delayControllers) make_persistent($autoRebow) make_persistent($noteMode) make_persistent($delayMode) make_persistent($legatoMode) make_persistent($lastDelayCCValue) make_persistent($lastDynamicCCValue) make_persistent($instrumentMode) make_persistent($shortsDelay) make_persistent($slowLegatoDelay) make_persistent($mediumLegatoDelay) make_persistent($fastLegatoDelay) make_persistent($sustainKeyswitch) make_persistent($staccatoKeyswitch) make_persistent($tremoloKeyswitch) make_persistent($harmonicsKeyswitch) make_persistent($trillsKeyswitch) make_persistent($measuredTremoloKeyswitch) make_persistent($marcatoKeyswitch) make_persistent($pizzicatoKeyswitch) make_persistent($legatoKeyswitch) make_persistent($conSordinoKeyswitch) {Read the persistent variables} read_persistent_var($keyswitchLow) read_persistent_var($keyswitchHigh) read_persistent_var($keyswitchCC) read_persistent_var($delayCC) read_persistent_var($dynamicCC) read_persistent_var($inputChannel) read_persistent_var($shortsMode) read_persistent_var($trillsMode) read_persistent_var($delayKeyswitching) read_persistent_var($delayControllers) read_persistent_var($autoRebow) read_persistent_var($noteMode) read_persistent_var($delayMode) read_persistent_var($legatoMode) read_persistent_var($lastDelayCCValue) read_persistent_var($lastDynamicCCValue) read_persistent_var($instrumentMode) read_persistent_var($shortsDelay) read_persistent_var($slowLegatoDelay) read_persistent_var($mediumLegatoDelay) read_persistent_var($fastLegatoDelay) read_persistent_var($firstLegatoDelay) read_persistent_var($sustainKeyswitch) read_persistent_var($staccatoKeyswitch) read_persistent_var($tremoloKeyswitch) read_persistent_var($harmonicsKeyswitch) read_persistent_var($trillsKeyswitch) read_persistent_var($measuredTremoloKeyswitch) read_persistent_var($marcatoKeyswitch) read_persistent_var($pizzicatoKeyswitch) read_persistent_var($legatoKeyswitch) read_persistent_var($conSordinoKeyswitch) {Set up low and high keyswitch ranges} %keyswitchArray[0] := $sustainKeyswitch %keyswitchArray[1] := $staccatoKeyswitch %keyswitchArray[2] := $tremoloKeyswitch %keyswitchArray[3] := $harmonicsKeyswitch %keyswitchArray[4] := $trillsKeyswitch %keyswitchArray[5] := $measuredTremoloKeyswitch %keyswitchArray[6] := $marcatoKeyswitch %keyswitchArray[7] := $pizzicatoKeyswitch %keyswitchArray[8] := $legatoKeyswitch %keyswitchArray[9] := $conSordinoKeyswitch {Sort the array to the lowest and highest range} $i := 0 while ($i < num_elements(%keyswitchArray)) %keyswitchSortArray[$i] := %keyswitchArray[$i] $i := $i + 1 end while sort(%keyswitchSortArray,0) $keyswitchLow := %keyswitchSortArray[0] $keyswitchHigh := %keyswitchSortArray[9] {UI Stuff} {Colours} declare $colourStrings declare $colourSoloStrings declare $colourBrass declare $colourWinds $colourStrings := 97b6db1h $colourSoloStrings := 988d3dbh $colourBrass := 9df705eh $colourWinds := 994cd8fh {Fixed name strings for Strings} declare @tremoloKeyswitchName declare @harmonicsKeyswitchName declare @measuredTremoloKeyswitchName declare @pizzicatoKeyswitchName @tremoloKeyswitchName := "Tremolo KS" @harmonicsKeyswitchName := "Harmonics KS" @measuredTremoloKeyswitchName := "Measured Trem KS" @pizzicatoKeyswitchName := "Pizzicato KS" {Fixed name strings for Brass} declare @mutedKeyswitchName declare @flutterKeyswitchName declare @doubleTongueKeyswitchName declare @ripsKeyswitchName @mutedKeyswitchName := "Muted KS" @flutterKeyswitchName := "Flutter KS" @doubleTongueKeyswitchName := "Dbl. Tongue KS" @ripsKeyswitchName := "Rips KS" {Tabs and Layout} declare ui_button $delayTabButton declare ui_button $helpTabButton declare ui_button $keyswitchTabButton declare ui_button $basicsTabButton declare ui_label $statusLabel(6,1) declare ui_label $trackDelayLabel(2,1) declare ui_button $startButton set_text($basicsTabButton,"Basics") set_text($helpTabButton,"Help") set_text($delayTabButton,"Delay") set_text($keyswitchTabButton,"Keyswitches") set_text($statusLabel, "") set_text($trackDelayLabel, "") set_text($startButton,"Start") move_control($helpTabButton,1,1) move_control($basicsTabButton,2,1) move_control($keyswitchTabButton,3,1) move_control($delayTabButton,4,1) move_control($statusLabel,1,2) move_control($trackDelayLabel,5,1) move_control($startButton,1,1) hide_part($helpTabButton,$HIDE_WHOLE_CONTROL) hide_part($basicsTabButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchTabButton,$HIDE_WHOLE_CONTROL) hide_part($delayTabButton,$HIDE_WHOLE_CONTROL) hide_part($trackDelayLabel,$HIDE_WHOLE_CONTROL) set_text($statusLabel,@disclaimer) {Basics Tab} declare ui_label $dynamicCCLabel(1,1) declare ui_value_edit $dynamicCCUI(0,127,1) set_text($dynamicCCLabel,"Dynamics CC") set_text($dynamicCCUI,"") declare ui_button $shortsCCButton declare ui_button $oneNoteTrillsButton declare ui_button $autoRebowButton declare ui_button $instrumentModeButton set_text($shortsCCButton,"CC Dyn. Shorts") set_text($oneNoteTrillsButton,"One Note Trills") set_text($autoRebowButton,"Auto Rebow Leg.") declare ui_label $inputChannelLabel(1,1) declare ui_value_edit $inputChannelUI(1,16,1) set_text($inputChannelLabel,"Input Channel") set_text($inputChannelUI,"") declare ui_label $keyswitchCCLabel(1,1) declare ui_value_edit $keyswitchCCUI(0,127,1) set_text($keyswitchCCLabel,"Keyswitch CC") set_text($keyswitchCCUI,"") declare ui_table %delayIndicatorTable[2] (1,1,1) move_control($inputChannelLabel,1,4) move_control($inputChannelUI,2,4) move_control($dynamicCCLabel,1,5) move_control($dynamicCCUI,2,5) move_control($keyswitchCCLabel,1,6) move_control($keyswitchCCUI,2,6) move_control($oneNoteTrillsButton,3,4) move_control($shortsCCButton,3,5) move_control($autoRebowButton,3,6) move_control($instrumentModeButton,1,3) move_control(%delayIndicatorTable,2,3) hide_part($inputChannelLabel,$HIDE_WHOLE_CONTROL) hide_part($inputChannelUI,$HIDE_WHOLE_CONTROL) hide_part($dynamicCCLabel,$HIDE_WHOLE_CONTROL) hide_part($dynamicCCUI,$HIDE_WHOLE_CONTROL) hide_part($oneNoteTrillsButton,$HIDE_WHOLE_CONTROL) hide_part($shortsCCButton,$HIDE_WHOLE_CONTROL) hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCUI,$HIDE_WHOLE_CONTROL) hide_part($instrumentModeButton,$HIDE_WHOLE_CONTROL) hide_part(%delayIndicatorTable,$HIDE_WHOLE_CONTROL) {Basics tab, if debug is active} declare ui_label $keyswitchValueLabel(1,1) declare ui_label $keyswitchValueOutput(1,1) set_text($keyswitchValueLabel,"Keyswitch CC Value") set_text($keyswitchValueOutput,"") declare ui_label $keyswitchCCRealValueLabel(1,1) declare ui_label $keyswitchCCRealValueOutput(1,1) set_text($keyswitchCCRealValueLabel,"Real Keyswitch CC Value") set_text($keyswitchCCRealValueOutput,"") declare ui_label $noteModeLabel(1,1) declare ui_label $noteModeOutput(1,1) set_text($noteModeLabel,"Note Mode") set_text($noteModeOutput,"") declare ui_label $legatoModeLabel(1,1) declare ui_label $legatoModeOutput(1,1) set_text($legatoModeLabel,"Legato Mode") set_text($legatoModeOutput,"") move_control($keyswitchValueLabel,5,3) move_control($keyswitchValueOutput,6,3) move_control($keyswitchCCRealValueLabel,5,4) move_control($keyswitchCCRealValueOutput,6,4) move_control($noteModeLabel,5,5) move_control($noteModeOutput,6,5) move_control($legatoModeLabel,5,6) move_control($legatoModeOutput,6,6) if ($debug # 1) hide_part($keyswitchValueLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchValueOutput,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCRealValueLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCRealValueOutput,$HIDE_WHOLE_CONTROL) hide_part($noteModeLabel,$HIDE_WHOLE_CONTROL) hide_part($noteModeOutput,$HIDE_WHOLE_CONTROL) hide_part($legatoModeLabel,$HIDE_WHOLE_CONTROL) hide_part($legatoModeOutput,$HIDE_WHOLE_CONTROL) end if {Help Tab} declare ui_label $basicsHelpLabel(2,1) declare ui_label $basicsHelpText(2,3) declare ui_label $keyswitchHelpLabel(2,1) declare ui_label $keyswitchHelpText(2,3) declare ui_label $delayHelpLabel(2,1) declare ui_label $delayHelpText(2,3) set_text($basicsHelpLabel,"Basics Tab") set_text($basicsHelpText,"Set the input channel of the instrument to delay. Options: One key trills, Dynamics CC controlled short notes") set_text($keyswitchHelpLabel,"Keyswitch Tab") set_text($keyswitchHelpText,"Adjust keyswitches and Keyswitch CC to match CSS values if changed. If incorrect, script will not work") set_text($delayHelpLabel,"Delay Tab") set_text($delayHelpText,"MS delay for different legato speeds or shorts. Set Delay CC if desired. Delay CC values above 64 enable delay") move_control($basicsHelpLabel,1,3) move_control($basicsHelpText,1,4) move_control($keyswitchHelpLabel,3,3) move_control($keyswitchHelpText,3,4) move_control($delayHelpLabel,5,3) move_control($delayHelpText,5,4) hide_part($basicsHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($basicsHelpText,$HIDE_WHOLE_CONTROL) hide_part($keyswitchHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchHelpText,$HIDE_WHOLE_CONTROL) hide_part($delayHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($delayHelpText,$HIDE_WHOLE_CONTROL) {Keyswitch Tab} declare ui_label $legatoKeyswitchLabel(1,1) declare ui_label $sustainKeyswitchLabel(1,1) declare ui_label $staccatoKeyswitchLabel(1,1) declare ui_label $tremoloKeyswitchLabel(1,1) declare ui_label $harmonicsKeyswitchLabel(1,1) declare ui_label $trillsKeyswitchLabel(1,1) declare ui_label $measuredTremoloKeyswitchLabel(1,1) declare ui_label $marcatoKeyswitchLabel(1,1) declare ui_label $pizzicatoKeyswitchLabel(1,1) declare ui_label $conSordinoKeyswitchLabel(1,1) declare ui_value_edit $legatoKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $sustainKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $staccatoKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $tremoloKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $harmonicsKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $trillsKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $measuredTremoloKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $marcatoKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $pizzicatoKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_value_edit $conSordinoKeyswitchUI(0,127,$VALUE_EDIT_MODE_NOTE_NAMES) declare ui_button $keyswitchUpButton declare ui_button $keyswitchDownButton declare ui_button $keyswitchDefaultButton set_text($legatoKeyswitchLabel,"Legato KS") set_text($legatoKeyswitchUI,"") set_text($sustainKeyswitchLabel,"Sustain KS") set_text($staccatoKeyswitchLabel,"Staccato KS") set_text($tremoloKeyswitchLabel,@tremoloKeyswitchName) set_text($harmonicsKeyswitchLabel,@harmonicsKeyswitchName) set_text($trillsKeyswitchLabel,"Trills KS") set_text($measuredTremoloKeyswitchLabel,@measuredTremoloKeyswitchName) set_text($marcatoKeyswitchLabel,"Marcato KS") set_text($pizzicatoKeyswitchLabel,@pizzicatoKeyswitchName) set_text($conSordinoKeyswitchLabel,"Con Sordino KS") set_text($sustainKeyswitchUI,"") set_text($staccatoKeyswitchUI,"") set_text($tremoloKeyswitchUI,"") set_text($harmonicsKeyswitchUI,"") set_text($trillsKeyswitchUI,"") set_text($measuredTremoloKeyswitchUI,"") set_text($marcatoKeyswitchUI,"") set_text($pizzicatoKeyswitchUI,"") set_text($conSordinoKeyswitchUI,"") set_text($keyswitchUpButton,"+8ve") set_text($keyswitchDownButton,"-8ve") set_text($keyswitchDefaultButton,"CSS Defaults") move_control($sustainKeyswitchLabel,1,3) move_control($sustainKeyswitchUI,2,3) move_control($staccatoKeyswitchLabel,3,3) move_control($staccatoKeyswitchUI,4,3) move_control($tremoloKeyswitchLabel,1,4) move_control($tremoloKeyswitchUI,2,4) move_control($harmonicsKeyswitchLabel,3,4) move_control($harmonicsKeyswitchUI,4,4) move_control($trillsKeyswitchLabel,1,5) move_control($trillsKeyswitchUI,2,5) move_control($measuredTremoloKeyswitchLabel,3,5) move_control($measuredTremoloKeyswitchUI,4,5) move_control($marcatoKeyswitchLabel,1,6) move_control($marcatoKeyswitchUI,2,6) move_control($pizzicatoKeyswitchLabel,3,6) move_control($pizzicatoKeyswitchUI,4,6) move_control($conSordinoKeyswitchLabel,5,4) move_control($conSordinoKeyswitchUI,6,4) move_control($legatoKeyswitchLabel,5,3) move_control($legatoKeyswitchUI,6,3) move_control($keyswitchUpButton,6,5) move_control($keyswitchDownButton,5,5) move_control($keyswitchDefaultButton,6,6) hide_part($legatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($legatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($sustainKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($staccatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($harmonicsKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($trillsKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($measuredTremoloKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($marcatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($sustainKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($staccatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($harmonicsKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($trillsKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($measuredTremoloKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($marcatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($keyswitchUpButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchDownButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchDefaultButton,$HIDE_WHOLE_CONTROL) {Delay Tab} {For per legato delay} declare ui_value_edit $shortsDelayUI (0,1000,1) declare ui_value_edit $slowLegatoDelayUI (0,1000,1) declare ui_value_edit $mediumLegatoDelayUI (0,1000,1) declare ui_value_edit $fastLegatoDelayUI (0,1000,1) declare ui_value_edit $firstLegatoDelayUI (0,1000,1) declare ui_label $shortsDelayLabel (1,1) declare ui_label $slowLegatoDelayLabel (1,1) declare ui_label $mediumLegatoDelayLabel (1,1) declare ui_label $fastLegatoDelayLabel (1,1) declare ui_label $firstLegatoDelayLabel (1,1) declare ui_button $delayKeyswitchingButton declare ui_button $delayControllersButton declare ui_button $delayModeButton declare ui_label $delayCCLabel(1,1) declare ui_value_edit $delayCCUI(0,127,1) declare ui_button $stringsDefaultDelayButton declare ui_button $brassDefaultDelayButton declare ui_button $trumpetsDefaultDelayButton declare ui_button $windsDefaultDelayButton set_text($shortsDelayUI,"") set_text($slowLegatoDelayUI,"") set_text($mediumLegatoDelayUI,"") set_text($fastLegatoDelayUI,"") set_text($firstLegatoDelayUI,"") set_text($shortsDelayLabel,"Shorts") set_text($slowLegatoDelayLabel,"Slow Legato") set_text($mediumLegatoDelayLabel,"Medium Legato") set_text($fastLegatoDelayLabel,"Fast Leg./Marcato") set_text($firstLegatoDelayLabel,"First Legato Note") set_text($delayKeyswitchingButton,"Delay KS/KS CC") set_text($delayControllersButton,"Delay non-KS CC") set_text($delayCCLabel,"Delay Control CC") set_text($delayCCUI,"") set_text($stringsDefaultDelayButton,"Strings Defaults") set_text($brassDefaultDelayButton,"Brass Defaults") set_text($trumpetsDefaultDelayButton,"Trumpets Defaults") set_text($windsDefaultDelayButton,"Winds Defaults") move_control($slowLegatoDelayLabel,1,3) move_control($slowLegatoDelayUI,2,3) move_control($mediumLegatoDelayLabel,1,4) move_control($mediumLegatoDelayUI,2,4) move_control($fastLegatoDelayLabel,1,5) move_control($fastLegatoDelayUI,2,5) move_control($firstLegatoDelayLabel,3,6) move_control($firstLegatoDelayUI,4,6) move_control($shortsDelayLabel,1,6) move_control($shortsDelayUI,2,6) move_control($delayControllersButton,5,3) move_control($delayKeyswitchingButton,5,4) move_control($delayModeButton,5,5) move_control($delayCCLabel,5,6) move_control($delayCCUI,6,6) move_control($stringsDefaultDelayButton,3,3) move_control($brassDefaultDelayButton,3,3) move_control($trumpetsDefaultDelayButton,3,4) move_control($windsDefaultDelayButton,3,3) hide_part($shortsDelayUI,$HIDE_WHOLE_CONTROL) hide_part($slowLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($mediumLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($fastLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($firstLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($shortsDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($slowLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($mediumLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($fastLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($firstLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($delayKeyswitchingButton,$HIDE_WHOLE_CONTROL) hide_part($delayControllersButton,$HIDE_WHOLE_CONTROL) hide_part($delayModeButton,$HIDE_WHOLE_CONTROL) hide_part($delayCCLabel,$HIDE_WHOLE_CONTROL) hide_part($delayCCUI,$HIDE_WHOLE_CONTROL) hide_part($stringsDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($brassDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($trumpetsDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($windsDefaultDelayButton,$HIDE_WHOLE_CONTROL) {Populate the UI} $keyswitchCCUI := $keyswitchCC $shortsDelayUI := $shortsDelay $slowLegatoDelayUI := $slowLegatoDelay $mediumLegatoDelayUI := $mediumLegatoDelay $fastLegatoDelayUI := $fastLegatoDelay $firstLegatoDelayUI := $firstLegatoDelay $legatoKeyswitchUI := $legatoKeyswitch $delayCCUI := $delayCC $dynamicCCUI := $dynamicCC $shortsCCButton := $shortsMode $autoRebowButton := $autoRebow $oneNoteTrillsButton := $trillsMode $delayModeButton := $delayMode $delayKeyswitchingButton := $delayKeyswitching $delayControllersButton := $delayControllers $inputChannelUI := $inputChannel + 1 $sustainKeyswitchUI := $sustainKeyswitch $staccatoKeyswitchUI := $staccatoKeyswitch $tremoloKeyswitchUI := $tremoloKeyswitch $harmonicsKeyswitchUI := $harmonicsKeyswitch $trillsKeyswitchUI := $trillsKeyswitch $measuredTremoloKeyswitchUI := $measuredTremoloKeyswitch $marcatoKeyswitchUI := $marcatoKeyswitch $pizzicatoKeyswitchUI := $pizzicatoKeyswitch $legatoKeyswitchUI := $legatoKeyswitch $conSordinoKeyswitchUI := $conSordinoKeyswitch end on {Makes the table light up if the delay is on} function BasicsTab_ToggleDelayIndicator if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) %delayIndicatorTable[0] := 1 %delayIndicatorTable[1] := 1 else %delayIndicatorTable[0] := 0 %delayIndicatorTable[1] := 0 end if end function {Control text and representation for Delay Mode Button} function DelayModeButton_Update if ($delayMode = 1) $delayModeButton := 1 set_text($delayModeButton, "Delay Always On") hide_part($delayCCLabel,$HIDE_WHOLE_CONTROL) hide_part($delayCCUI,$HIDE_WHOLE_CONTROL) else $delayModeButton := 0 set_text($delayModeButton, "CC Controls Delay") hide_part($delayCCLabel,$HIDE_PART_NOTHING) hide_part($delayCCUI,$HIDE_PART_NOTHING) end if call BasicsTab_ToggleDelayIndicator end function function DelayModeButton_Control if ($delayModeButton = 1) $delayMode := 1 set_text($delayModeButton, "Delay Always On") hide_part($delayCCLabel,$HIDE_WHOLE_CONTROL) hide_part($delayCCUI,$HIDE_WHOLE_CONTROL) else $delayMode := 0 set_text($delayModeButton, "CC Controls Delay") hide_part($delayCCLabel,$HIDE_PART_NOTHING) hide_part($delayCCUI,$HIDE_PART_NOTHING) end if call BasicsTab_ToggleDelayIndicator end function {Show functions used by strings} function SetFunctions_Strings set_text($instrumentModeButton, "Strings Mode") hide_part($autoRebowButton,$HIDE_PART_NOTHING) set_text($tremoloKeyswitchLabel,@tremoloKeyswitchName) set_text($harmonicsKeyswitchLabel,@harmonicsKeyswitchName) set_text($measuredTremoloKeyswitchLabel,@measuredTremoloKeyswitchName) set_text($pizzicatoKeyswitchLabel,@pizzicatoKeyswitchName) set_text($keyswitchDefaultButton,"CSS Defaults") set_control_par(get_ui_id(%delayIndicatorTable),$CONTROL_PAR_BAR_COLOR,$colourStrings) end function {Show functions used by brass} function SetFunctions_Brass set_text($instrumentModeButton, "Brass Mode") hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) $autoRebowButton := 0 $autoRebow := 0 set_text($tremoloKeyswitchLabel,@mutedKeyswitchName) set_text($harmonicsKeyswitchLabel,@flutterKeyswitchName) set_text($measuredTremoloKeyswitchLabel,@doubleTongueKeyswitchName) set_text($pizzicatoKeyswitchLabel,@ripsKeyswitchName) set_text($keyswitchDefaultButton,"CSB Defaults") set_control_par(get_ui_id(%delayIndicatorTable),$CONTROL_PAR_BAR_COLOR,$colourBrass) end function function SetFunctions_Winds set_text($instrumentModeButton, "Winds Mode") hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) $autoRebowButton := 0 $autoRebow := 0 {#REF define what the keyswitch labels should be} set_text($harmonicsKeyswitchLabel,@flutterKeyswitchName) set_text($measuredTremoloKeyswitchLabel,@doubleTongueKeyswitchName) set_text($keyswitchDefaultButton,"CSW Defaults") set_control_par(get_ui_id(%delayIndicatorTable),$CONTROL_PAR_BAR_COLOR,$colourWinds) end function function InstrumentFunctions_Update select ($instrumentMode) case 0 call SetFunctions_Strings case 1 call SetFunctions_Brass case 2 call SetFunctions_Winds end select end function function InstrumentModeButton_Control select ($instrumentMode) case 0 $instrumentMode := 1 case 1 $instrumentMode := 2 case 2 $instrumentMode := 0 end select call InstrumentFunctions_Update end function {Made based on the assumption that people want keyswitches contiguous} function CalculateKeyswitchLimits %keyswitchArray[0] := $sustainKeyswitch %keyswitchArray[1] := $staccatoKeyswitch %keyswitchArray[2] := $tremoloKeyswitch %keyswitchArray[3] := $harmonicsKeyswitch %keyswitchArray[4] := $trillsKeyswitch %keyswitchArray[5] := $measuredTremoloKeyswitch %keyswitchArray[6] := $marcatoKeyswitch %keyswitchArray[7] := $pizzicatoKeyswitch %keyswitchArray[8] := $legatoKeyswitch %keyswitchArray[9] := $conSordinoKeyswitch $i := 0 while ($i < num_elements(%keyswitchArray)) %keyswitchSortArray[$i] := %keyswitchArray[$i] $i := $i + 1 end while sort(%keyswitchSortArray,0) $keyswitchLow := %keyswitchSortArray[0] $keyswitchHigh := %keyswitchSortArray[9] end function function KeyswitchTab_UpdateKeys $sustainKeyswitchUI := $sustainKeyswitch $staccatoKeyswitchUI := $staccatoKeyswitch $tremoloKeyswitchUI := $tremoloKeyswitch $harmonicsKeyswitchUI := $harmonicsKeyswitch $trillsKeyswitchUI := $trillsKeyswitch $measuredTremoloKeyswitchUI := $measuredTremoloKeyswitch $marcatoKeyswitchUI := $marcatoKeyswitch $pizzicatoKeyswitchUI := $pizzicatoKeyswitch $legatoKeyswitchUI := $legatoKeyswitch $conSordinoKeyswitchUI := $conSordinoKeyswitch call CalculateKeyswitchLimits end function function KeyswitchTab_SetDefaults $sustainKeyswitch := 24 $staccatoKeyswitch := 29 $tremoloKeyswitch := 25 $harmonicsKeyswitch := 28 $trillsKeyswitch := 27 $measuredTremoloKeyswitch := 26 $marcatoKeyswitch := 30 $pizzicatoKeyswitch := 31 select ($instrumentMode) case 0 $legatoKeyswitch := 34 $conSordinoKeyswitch := 35 case 1 $legatoKeyswitch := 34 $conSordinoKeyswitch := 23 case 2 $legatoKeyswitch := 32 $conSordinoKeyswitch := 23 end select call KeyswitchTab_UpdateKeys end function function KeyswitchTab_OctaveDown $sustainKeyswitch := $sustainKeyswitch - 12 $staccatoKeyswitch := $staccatoKeyswitch - 12 $tremoloKeyswitch := $tremoloKeyswitch - 12 $harmonicsKeyswitch := $harmonicsKeyswitch - 12 $trillsKeyswitch := $trillsKeyswitch - 12 $measuredTremoloKeyswitch := $measuredTremoloKeyswitch - 12 $marcatoKeyswitch := $marcatoKeyswitch - 12 $pizzicatoKeyswitch := $pizzicatoKeyswitch - 12 $legatoKeyswitch := $legatoKeyswitch - 12 $conSordinoKeyswitch := $conSordinoKeyswitch - 12 call KeyswitchTab_UpdateKeys end function function KeyswitchTab_OctaveUp $sustainKeyswitch := $sustainKeyswitch + 12 $staccatoKeyswitch := $staccatoKeyswitch + 12 $tremoloKeyswitch := $tremoloKeyswitch + 12 $harmonicsKeyswitch := $harmonicsKeyswitch + 12 $trillsKeyswitch := $trillsKeyswitch + 12 $measuredTremoloKeyswitch := $measuredTremoloKeyswitch + 12 $marcatoKeyswitch := $marcatoKeyswitch + 12 $pizzicatoKeyswitch := $pizzicatoKeyswitch + 12 $legatoKeyswitch := $legatoKeyswitch + 12 $conSordinoKeyswitch := $conSordinoKeyswitch + 12 call KeyswitchTab_UpdateKeys end function function DelayTab_UpdateDelays $shortsDelayUI := $shortsDelay $slowLegatoDelayUI := $slowLegatoDelay $mediumLegatoDelayUI := $mediumLegatoDelay $fastLegatoDelayUI := $fastLegatoDelay $firstLegatoDelayUI := $firstLegatoDelay set_text($trackDelayLabel,"Set track delay to: -" & $slowLegatoDelay & "ms") end function function DelayTab_SetDefaults_Strings $shortsDelay := $shortsDelay_General $slowLegatoDelay := $slowLegatoDelay_Strings $mediumLegatoDelay := $mediumLegatoDelay_Strings $fastLegatoDelay := $fastLegatoDelay_General $firstLegatoDelay := $firstLegatoDelay_General call DelayTab_UpdateDelays end function function DelayTab_SetDefaults_Brass $shortsDelay := $shortsDelay_General $slowLegatoDelay := $mediumLegatoDelay_Brass $mediumLegatoDelay := $mediumLegatoDelay_Brass $fastLegatoDelay := $fastLegatoDelay_General $firstLegatoDelay := $firstLegatoDelay_General call DelayTab_UpdateDelays end function function DelayTab_SetDefaults_Trumpets $shortsDelay := $shortsDelay_General $slowLegatoDelay := $mediumLegatoDelay_Trumpets $mediumLegatoDelay := $mediumLegatoDelay_Trumpets $fastLegatoDelay := $fastLegatoDelay_General $firstLegatoDelay := $firstLegatoDelay_General call DelayTab_UpdateDelays end function function DelayTab_SetDefaults_Winds $shortsDelay := $shortsDelay_General $slowLegatoDelay := $slowLegatoDelay_Winds $mediumLegatoDelay := $mediumLegatoDelay_Winds $fastLegatoDelay := $fastLegatoDelay_Winds $firstLegatoDelay := $firstLegatoDelay_Winds call DelayTab_UpdateDelays end function {Verbose nonsense to show and hide multiple UI elements at the same time, giving the illusion of a tabbed UI} function BasicsTab_Show $basicsTabButton := 1 hide_part($dynamicCCLabel,$HIDE_PART_NOTHING) hide_part($dynamicCCUI,$HIDE_PART_NOTHING) hide_part($shortsCCButton,$HIDE_PART_NOTHING) hide_part($oneNoteTrillsButton,$HIDE_PART_NOTHING) hide_part($inputChannelLabel,$HIDE_PART_NOTHING) hide_part($inputChannelUI,$HIDE_PART_NOTHING) hide_part($keyswitchCCLabel,$HIDE_PART_NOTHING) hide_part($keyswitchCCUI,$HIDE_PART_NOTHING) hide_part($instrumentModeButton,$HIDE_PART_NOTHING) hide_part(%delayIndicatorTable,$HIDE_PART_NOTHING) {Hide things only needed for certain instruments} select ($instrumentMode) case 0 hide_part($autoRebowButton,$HIDE_PART_NOTHING) case 1 hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) case 2 hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) end select end function function BasicsTab_Hide $basicsTabButton := 0 hide_part($dynamicCCLabel,$HIDE_WHOLE_CONTROL) hide_part($dynamicCCUI,$HIDE_WHOLE_CONTROL) hide_part($shortsCCButton,$HIDE_WHOLE_CONTROL) hide_part($oneNoteTrillsButton,$HIDE_WHOLE_CONTROL) hide_part($autoRebowButton,$HIDE_WHOLE_CONTROL) hide_part($inputChannelLabel,$HIDE_WHOLE_CONTROL) hide_part($inputChannelUI,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchCCUI,$HIDE_WHOLE_CONTROL) hide_part($instrumentModeButton,$HIDE_WHOLE_CONTROL) hide_part(%delayIndicatorTable,$HIDE_WHOLE_CONTROL) end function function HelpTab_Show $helpTabButton := 1 hide_part($basicsHelpLabel,$HIDE_PART_NOTHING) hide_part($basicsHelpText,$HIDE_PART_NOTHING) hide_part($keyswitchHelpLabel,$HIDE_PART_NOTHING) hide_part($keyswitchHelpText,$HIDE_PART_NOTHING) hide_part($delayHelpLabel,$HIDE_PART_NOTHING) hide_part($delayHelpText,$HIDE_PART_NOTHING) set_text($statusLabel,@disclaimer) end function function HelpTab_Hide $helpTabButton := 0 hide_part($basicsHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($basicsHelpText,$HIDE_WHOLE_CONTROL) hide_part($keyswitchHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($keyswitchHelpText,$HIDE_WHOLE_CONTROL) hide_part($delayHelpLabel,$HIDE_WHOLE_CONTROL) hide_part($delayHelpText,$HIDE_WHOLE_CONTROL) set_text($statusLabel,"") end function function DelayTab_Show $delayTabButton := 1 hide_part($shortsDelayUI,$HIDE_PART_NOTHING) hide_part($mediumLegatoDelayUI,$HIDE_PART_NOTHING) hide_part($fastLegatoDelayUI,$HIDE_PART_NOTHING) hide_part($firstLegatoDelayUI,$HIDE_PART_NOTHING) hide_part($shortsDelayLabel,$HIDE_PART_NOTHING) hide_part($mediumLegatoDelayLabel,$HIDE_PART_NOTHING) hide_part($fastLegatoDelayLabel,$HIDE_PART_NOTHING) hide_part($firstLegatoDelayLabel,$HIDE_PART_NOTHING) hide_part($delayKeyswitchingButton,$HIDE_PART_NOTHING) hide_part($delayControllersButton,$HIDE_PART_NOTHING) hide_part($delayModeButton,$HIDE_PART_NOTHING) hide_part($delayCCLabel,$HIDE_PART_NOTHING) hide_part($delayCCUI,$HIDE_PART_NOTHING) select ($instrumentMode) case 0 hide_part($stringsDefaultDelayButton,$HIDE_PART_NOTHING) hide_part($slowLegatoDelayUI,$HIDE_PART_NOTHING) hide_part($slowLegatoDelayLabel,$HIDE_PART_NOTHING) case 1 hide_part($brassDefaultDelayButton,$HIDE_PART_NOTHING) hide_part($trumpetsDefaultDelayButton,$HIDE_PART_NOTHING) case 2 hide_part($windsDefaultDelayButton,$HIDE_PART_NOTHING) hide_part($slowLegatoDelayUI,$HIDE_PART_NOTHING) hide_part($slowLegatoDelayLabel,$HIDE_PART_NOTHING) end select call DelayModeButton_Update call DelayTab_UpdateDelays end function function DelayTab_Hide $delayTabButton := 0 hide_part($shortsDelayUI,$HIDE_WHOLE_CONTROL) hide_part($slowLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($mediumLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($fastLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($firstLegatoDelayUI,$HIDE_WHOLE_CONTROL) hide_part($shortsDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($slowLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($mediumLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($fastLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($firstLegatoDelayLabel,$HIDE_WHOLE_CONTROL) hide_part($delayKeyswitchingButton,$HIDE_WHOLE_CONTROL) hide_part($delayControllersButton,$HIDE_WHOLE_CONTROL) hide_part($delayModeButton,$HIDE_WHOLE_CONTROL) hide_part($delayCCLabel,$HIDE_WHOLE_CONTROL) hide_part($delayCCUI,$HIDE_WHOLE_CONTROL) hide_part($stringsDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($brassDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($trumpetsDefaultDelayButton,$HIDE_WHOLE_CONTROL) hide_part($windsDefaultDelayButton,$HIDE_WHOLE_CONTROL) end function function KeyswitchTab_Show $keyswitchTabButton := 1 hide_part($legatoKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($legatoKeyswitchUI,$HIDE_PART_NOTHING) hide_part($sustainKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($staccatoKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($tremoloKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($harmonicsKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($trillsKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($measuredTremoloKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($marcatoKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($pizzicatoKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($sustainKeyswitchUI,$HIDE_PART_NOTHING) hide_part($staccatoKeyswitchUI,$HIDE_PART_NOTHING) hide_part($tremoloKeyswitchUI,$HIDE_PART_NOTHING) hide_part($harmonicsKeyswitchUI,$HIDE_PART_NOTHING) hide_part($trillsKeyswitchUI,$HIDE_PART_NOTHING) hide_part($measuredTremoloKeyswitchUI,$HIDE_PART_NOTHING) hide_part($marcatoKeyswitchUI,$HIDE_PART_NOTHING) hide_part($pizzicatoKeyswitchUI,$HIDE_PART_NOTHING) hide_part($keyswitchUpButton,$HIDE_PART_NOTHING) hide_part($keyswitchDownButton,$HIDE_PART_NOTHING) hide_part($keyswitchDefaultButton,$HIDE_PART_NOTHING) select ($instrumentMode) case 0 move_control($trillsKeyswitchLabel,1,5) move_control($trillsKeyswitchUI,2,5) move_control($marcatoKeyswitchLabel,1,6) move_control($marcatoKeyswitchUI,2,6) hide_part($conSordinoKeyswitchLabel,$HIDE_PART_NOTHING) hide_part($conSordinoKeyswitchUI,$HIDE_PART_NOTHING) case 1 move_control($trillsKeyswitchLabel,1,5) move_control($trillsKeyswitchUI,2,5) move_control($marcatoKeyswitchLabel,1,6) move_control($marcatoKeyswitchUI,2,6) hide_part($conSordinoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchUI,$HIDE_WHOLE_CONTROL) case 2 move_control($trillsKeyswitchLabel,1,4) move_control($trillsKeyswitchUI,2,4) move_control($marcatoKeyswitchLabel,1,5) move_control($marcatoKeyswitchUI,2,5) hide_part($conSordinoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchUI,$HIDE_WHOLE_CONTROL) end select end function function KeyswitchTab_Hide $keyswitchTabButton := 0 hide_part($legatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($legatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($sustainKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($staccatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($harmonicsKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($trillsKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($measuredTremoloKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($marcatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchLabel,$HIDE_WHOLE_CONTROL) hide_part($sustainKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($staccatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($tremoloKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($harmonicsKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($trillsKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($measuredTremoloKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($marcatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($pizzicatoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($conSordinoKeyswitchUI,$HIDE_WHOLE_CONTROL) hide_part($keyswitchUpButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchDownButton,$HIDE_WHOLE_CONTROL) hide_part($keyswitchDefaultButton,$HIDE_WHOLE_CONTROL) end function {Just tells the user what is going on} function UpdateDebug if ($debug = 1) set_text($keyswitchValueOutput,$keyswitchNote & "(" & $keyswitchVelocity & ")") set_text($keyswitchCCRealValueOutput,%CC[$keyswitchCC]) set_text($noteModeOutput,$noteMode) set_text($legatoModeOutput,$legatoMode) end if end function {Sets the value of noteMode, based on the values defined by CSS's keyswitch CC} function SetNoteMode {There seems to be an inherrant latency with testing the CC's value in the same callback, so wait a moment} wait (2) select(%CC[$keyswitchCC]) case 0 to 5 {Standard Legato} {Test whether we're using CSS, CSB or CSW here} select ($instrumentMode) case 0 $noteMode := 4 set_text($statusLabel,"Articulation updated to sustain/standard legato") case 1 $noteMode := 4 set_text($statusLabel,"Articulation updated to sustain/standard legato") case 2 $noteMode := 5 set_text($statusLabel,"Articulation updated to sustain/advanced legato") end select case 6 to 10 {Advanced Legato} {Test whether we're using CSS, CSB or CSW here} select ($instrumentMode) case 0 $noteMode := 5 set_text($statusLabel,"Articulation updated to sustain/advanced legato") case 1 $noteMode := 4 set_text($statusLabel,"Articulation updated to sustain/standard legato") case 2 $noteMode := 5 set_text($statusLabel,"Articulation updated to sustain/advanced legato") end select case 11 to 45 {Shorts} $noteMode := 1 set_text($statusLabel,"Articulation updated to shorts") case 46 to 47 {Half Trills} $noteMode := 2 set_text($statusLabel,"Articulation updated to minor trills") case 48 to 50 {Whole Trills} $noteMode := 3 set_text($statusLabel,"Articulation updated to major trills") case 51 to 75 {General Longs} $noteMode := 0 set_text($statusLabel,"Articulation updated to general longs") case 76 to 85 {Turning on or off Legato} if (in_range(%CC[$keyswitchCC],76,80)) $legatoMode := 1 set_text($statusLabel,"Legato turned on") end if if (in_range(%CC[$keyswitchCC],81,85)) $legatoMode := 0 set_text($statusLabel,"Legato turned off") end if end select call UpdateDebug end function {#REF This needs looking at generally against CSW keyswitches} {Sets noteMode based on input values for keyswitches} function SetNoteMode_Keyswitch {Keyswitches have a velocity associated, so we need to test both bytes} if ($keyswitchNote = $sustainKeyswitch) select ($instrumentMode) case 0 if (in_range($keyswitchVelocity,0,64)) {Standard Legato} $noteMode := 4 end if if (in_range($keyswitchVelocity,65,127)) {Advanced Legato} $noteMode := 5 end if case 1 {Standard Legato} $noteMode := 4 case 2 {Advanced Legato} $noteMode := 5 end select end if if ($keyswitchNote = $tremoloKeyswitch) {Tremolo Longs or Muted in brass} select ($instrumentMode) case 0 {Tremolo} $noteMode := 0 case 1 if (in_range($keyswitchVelocity,0,64)) {Muted Shorts} $noteMode := 1 else {Muted Longs} $noteMode := 0 end if end select end if if ($keyswitchNote = $harmonicsKeyswitch) {Harmonics Longs} $noteMode := 0 end if if ($keyswitchNote = $measuredTremoloKeyswitch) {Measured Tremolo Longs} $noteMode := 0 end if if ($keyswitchNote = $marcatoKeyswitch) {Marcato Longs} if (in_range($keyswitchVelocity,0,64)) {Standard Legato} $noteMode := 0 else {Advanced Legato} $noteMode := 0 end if end if if ($keyswitchNote = $staccatoKeyswitch) {Staccato} if (in_range($keyswitchVelocity,0, 32)) $noteMode := 1 end if if (in_range($keyswitchVelocity,33, 64)) $noteMode := 1 end if if (in_range($keyswitchVelocity,65, 96)) $noteMode := 1 end if if (in_range($keyswitchVelocity,97, 127)) $noteMode := 1 end if end if if ($keyswitchNote = $pizzicatoKeyswitch) {Pizzicato} if (in_range($keyswitchVelocity,0, 41)) $noteMode := 1 end if if (in_range($keyswitchVelocity,42, 84)) $noteMode := 1 end if if (in_range($keyswitchVelocity,85, 127)) $noteMode := 1 end if end if if ($keyswitchNote = $trillsKeyswitch) if (in_range($keyswitchVelocity,0,64)) {Half Trills} $noteMode := 2 else {Whole Trills} $noteMode := 3 end if end if if ($legatoKeyswitchNote = $legatoKeyswitch) {Turning on Legato} if (in_range($legatoKeyswitchVelocity,0,64)) $legatoMode := 0 else $legatoMode := 1 end if end if call UpdateDebug end function function Start hide_part($delayTabButton,$HIDE_PART_NOTHING) hide_part($helpTabButton,$HIDE_PART_NOTHING) hide_part($keyswitchTabButton,$HIDE_PART_NOTHING) hide_part($basicsTabButton,$HIDE_PART_NOTHING) hide_part($trackDelayLabel,$HIDE_PART_NOTHING) call BasicsTab_ToggleDelayIndicator call InstrumentFunctions_Update call DelayTab_UpdateDelays call KeyswitchTab_Hide call DelayTab_Hide call HelpTab_Hide call BasicsTab_Show end function {Tab Controls} on ui_control ($startButton) hide_part($startButton,$HIDE_WHOLE_CONTROL) call Start end on on ui_control ($basicsTabButton) call KeyswitchTab_Hide call DelayTab_Hide call HelpTab_Hide call BasicsTab_Show end on on ui_control ($helpTabButton) call KeyswitchTab_Hide call DelayTab_Hide call BasicsTab_Hide call HelpTab_Show end on on ui_control ($delayTabButton) call BasicsTab_Hide call KeyswitchTab_Hide call HelpTab_Hide call DelayTab_Show end on on ui_control ($keyswitchTabButton) call BasicsTab_Hide call DelayTab_Hide call HelpTab_Hide call KeyswitchTab_Show end on {UI Controls} on ui_control ($keyswitchCCUI) $keyswitchCC := $keyswitchCCUI end on on ui_control ($shortsDelayUI) $shortsDelay := $shortsDelayUI call DelayTab_UpdateDelays end on on ui_control ($slowLegatoDelayUI) $slowLegatoDelay := $slowLegatoDelayUI call DelayTab_UpdateDelays end on on ui_control ($mediumLegatoDelayUI) $mediumLegatoDelay := $mediumLegatoDelayUI call DelayTab_UpdateDelays end on on ui_control ($fastLegatoDelayUI) $fastLegatoDelay := $fastLegatoDelayUI call DelayTab_UpdateDelays end on on ui_control ($firstLegatoDelayUI) $firstLegatoDelay := $firstLegatoDelayUI call DelayTab_UpdateDelays end on on ui_control ($delayCCUI) $delayCC := $delayCCUI end on on ui_control ($dynamicCCUI) $dynamicCC := $dynamicCCUI end on on ui_control ($shortsCCButton) if ($shortsCCButton = 1) $shortsMode := 1 else $shortsMode := 0 end if end on on ui_control ($oneNoteTrillsButton) if ($oneNoteTrillsButton = 1) $trillsMode := 1 else $trillsMode := 0 end if end on on ui_control ($autoRebowButton) if ($autoRebowButton = 1) $autoRebow := 1 else $autoRebow := 0 end if end on on ui_control ($delayKeyswitchingButton) if ($delayKeyswitchingButton = 1) $delayKeyswitching := 1 else $delayKeyswitching := 0 end if end on on ui_control ($delayControllersButton) if ($delayControllersButton = 1) $delayControllers := 1 else $delayControllers := 0 end if end on {Sets the correct value of the delay mode button and hides the CC if not relevant} on ui_control ($delayModeButton) call DelayModeButton_Control end on {Sets the correct value of the instrument mode button and hides things if not relevant} on ui_control ($instrumentModeButton) call InstrumentModeButton_Control $instrumentModeButton := 0 end on on ui_control ($inputChannelUI) $inputChannel := $inputChannelUI - 1 end on on ui_control ($legatoKeyswitchUI) $legatoKeyswitch := $legatoKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($sustainKeyswitchUI) $sustainKeyswitch := $sustainKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($staccatoKeyswitchUI) $staccatoKeyswitch := $staccatoKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($tremoloKeyswitchUI) $tremoloKeyswitch := $tremoloKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($harmonicsKeyswitchUI) $harmonicsKeyswitch := $harmonicsKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($trillsKeyswitchUI) $trillsKeyswitch := $trillsKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($measuredTremoloKeyswitchUI) $measuredTremoloKeyswitch := $measuredTremoloKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($marcatoKeyswitchUI) $marcatoKeyswitch := $marcatoKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($pizzicatoKeyswitchUI) $pizzicatoKeyswitch := $pizzicatoKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($conSordinoKeyswitchUI) $conSordinoKeyswitch := $conSordinoKeyswitchUI call CalculateKeyswitchLimits end on on ui_control ($keyswitchUpButton) call KeyswitchTab_OctaveUp $keyswitchUpButton := 0 end on on ui_control ($keyswitchDownButton) call KeyswitchTab_OctaveDown $keyswitchDownButton := 0 end on on ui_control ($keyswitchDefaultButton) call KeyswitchTab_SetDefaults $keyswitchDefaultButton := 0 end on on ui_control ($stringsDefaultDelayButton) call DelayTab_SetDefaults_Strings $stringsDefaultDelayButton := 0 end on on ui_control ($brassDefaultDelayButton) call DelayTab_SetDefaults_Brass $brassDefaultDelayButton := 0 end on on ui_control ($trumpetsDefaultDelayButton) call DelayTab_SetDefaults_Trumpets $trumpetsDefaultDelayButton := 0 end on on ui_control ($windsDefaultDelayButton) call DelayTab_SetDefaults_Winds $windsDefaultDelayButton := 0 end on on ui_control (%delayIndicatorTable) call BasicsTab_ToggleDelayIndicator end on {ON MIDI IN, we process if the command is CC, note_on or note_off} on midi_in {MIDI CC} if ($MIDI_COMMAND = $MIDI_COMMAND_CC and $MIDI_CHANNEL = $inputChannel) if ($MIDI_BYTE_1 = 123) {NOTE, this particular thing is causing seek issues} {The reason it exists is to stop notes hanging and doing stupid things} {Rather than just set everything to 0 when this happens, it is probably better to query again what we should be doing} {Or not, evidently Cubase doesn't send anything if seeking and in an articulation that it is already in (bit of an assumption!)} {call SetNoteMode_Keyswitch} {call SetNoteMode} $legatoNoteCount := 0 if ($autoRebow = 1) set_midi($inputChannel,$MIDI_COMMAND_CC,64,0) end if {Added an explicit note off here for the last pitch played if from a legato note, just in case this is hanging} set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$legatoNotePitch,1) set_text($statusLabel,"All notes stop") end if if ($MIDI_BYTE_1 = $delayCC) {Was going to affect delay on this like other CCs, but I think it is pointless} {User probably wants to turn on the delay immediately} $lastDelayCCValue := %CC[$delayCC] call BasicsTab_ToggleDelayIndicator end if if ($MIDI_BYTE_1 = $keyswitchCC) call SetNoteMode if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) if ($delayKeyswitching = 1) ignore_midi {Delay the keyswitch CC itself if we're already in a destination noteMode} select ($noteMode) case 0 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 1 wait (($slowLegatoDelay - $shortsDelay - 2) * 1000) case 2 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 3 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 4 {Just calling it out, do nothing here} wait(1) case 5 {Just calling it out, do nothing here} wait(1) end select set_midi($inputChannel,$MIDI_COMMAND_CC,$MIDI_BYTE_1,$MIDI_BYTE_2) end if end if end if if ($MIDI_BYTE_1 = $dynamicCC) $lastDynamicCCValue := %CC[$dynamicCC] if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) if ($delayControllers = 1) ignore_midi {Delay the keyswitch CC itself if we're already in a destination noteMode} select ($noteMode) case 0 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 1 wait (($slowLegatoDelay - $shortsDelay - 2) * 1000) case 2 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 3 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 4 {Just calling it out, do nothing here} wait(1) case 5 {Just calling it out, do nothing here} wait(1) end select set_midi($inputChannel,$MIDI_COMMAND_CC,$MIDI_BYTE_1,$MIDI_BYTE_2) end if end if end if if (($MIDI_BYTE_1 # $dynamicCC) and ($MIDI_BYTE_1 # $keyswitchCC) and ($MIDI_BYTE_1 # $delayCC) and ($MIDI_BYTE_1 # 123)) if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) if ($delayControllers = 1) ignore_midi wait (($slowLegatoDelay - 2) * 1000) set_midi($inputChannel,$MIDI_COMMAND_CC,$MIDI_BYTE_1,$MIDI_BYTE_2) end if end if end if call UpdateDebug end if {MIDI NOTE ON} if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_ON and $MIDI_BYTE_2 > 0 and $MIDI_CHANNEL = $inputChannel) {Check if the note being played is the legato keyswitch} if (in_range($EVENT_NOTE,$keyswitchLow,$keyswitchHigh)) ignore_midi if($MIDI_BYTE_1 = $legatoKeyswitch) $legatoKeyswitchNote := $MIDI_BYTE_1 $legatoKeyswitchVelocity := $MIDI_BYTE_2 else $keyswitchNote := $MIDI_BYTE_1 $keyswitchVelocity := $MIDI_BYTE_2 end if call SetNoteMode_Keyswitch if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) if ($delayKeyswitching = 1) {Delay the keyswitch itself if we're already in a destination noteMode} select ($noteMode) case 0 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 1 wait (($slowLegatoDelay - $shortsDelay - 2) * 1000) case 2 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 3 wait (($slowLegatoDelay - $fastLegatoDelay - 2) * 1000) case 4 {Just calling it out, do nothing here} wait(1) case 5 {Just calling it out, do nothing here} wait(1) end select end if end if set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if {Check we're not playing a keyswitch} if(not in_range($EVENT_NOTE,$keyswitchLow,$keyswitchHigh)) ignore_midi $lastDelayCCValue := %CC[$delayCC] wait(2) {Check what type of delay is required, then play a note} select ($noteMode) {Any other note that isn't a trill or short} case 0 $legatoNoteCount := 0 $legatoMode := 0 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"Long note " & $MIDI_BYTE_1 & " with delay of " & $lastDelay) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) {Shorts} case 1 $legatoNoteCount := 0 $legatoMode := 0 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $shortsDelay) * 1000) $lastDelay := $shortsDelay else $lastDelay := 0 end if if ($shortsMode = 1) {Check the dynamic CC again, in case it has changed during or in synchronicity with this event} $lastDynamicCCValue := %CC[$dynamicCC] set_text($statusLabel,"Short note " & $MIDI_BYTE_1 & " with delay of " & $lastDelay & " (Dynamic Shorts on)") set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$lastDynamicCCValue) else set_text($statusLabel,"Short note " & $MIDI_BYTE_1 & " with delay of " & $lastDelay) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if {Minor trills} case 2 $legatoNoteCount := 0 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if if ($trillsMode = 1) {Play the original note, and a note a semi tone above it for a moment. Note off anything we might have lying around} set_text($statusLabel,"Half note trill " & $MIDI_BYTE_1 & " with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount & ", Trills Mode On") set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1+1,$MIDI_BYTE_2) set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1+2,0) set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1+1,0) else set_text($statusLabel,"Trill on " & $MIDI_BYTE_1 & " with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount & ", Trills Mode Off") set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if {Major trills} case 3 $legatoNoteCount := 0 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if if ($trillsMode = 1) {Play the original note, and a note a tone above it for a moment. Note off anything we might have lying around} set_text($statusLabel,"Whole note trill " & $MIDI_BYTE_1 & " with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount & ", Trills Mode On") set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1+2,$MIDI_BYTE_2) set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1+1,0) set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1+2,0) else set_text($statusLabel,"Trill on " & $MIDI_BYTE_1 & " with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount & ", Trills Mode Off") set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if {Standard Legato for CSS and used exclusively by CSB} case 4 if ($legatoMode = 1) if ($legatoNoteCount > 0) select ($MIDI_BYTE_2) case 0 to 20 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) $lastDelay := $slowLegatoDelay else $lastDelay := 0 end if $lastDelay := $slowLegatoDelay {Only CSS has portamento on the low velocity} select ($instrumentMode) case 0 set_text($statusLabel,"Portamento note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) case 1 set_text($statusLabel,"Medium legato note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) end select case 21 to 64 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $mediumLegatoDelay) * 1000) $lastDelay := $mediumLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"Medium legato note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) case 65 to 127 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"Fast legato note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) end select if($autoRebow = 1) set_midi($inputChannel,$MIDI_COMMAND_CC,64,127) end if else if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $firstLegatoDelay) * 1000) $lastDelay := $firstLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"First legato note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) end if if($autoRebow = 1) set_midi($inputChannel,$MIDI_COMMAND_CC,64,127) end if set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) $legatoNoteCount := $legatoNoteCount + 1 $legatoNotePitch := $MIDI_BYTE_1 else if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if $legatoNoteCount := 0 set_text($statusLabel,"Sustain note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if {Advanced Legato, only used by CSS and exclusively by CSW} case 5 if ($legatoMode = 1) {Check if this is the first note in a legato sequence} if ($legatoNoteCount > 0) select ($MIDI_BYTE_2) case 0 to 64 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) $lastDelay := $slowLegatoDelay else $lastDelay := 0 end if $lastDelay := $slowLegatoDelay set_text($statusLabel,"Slow or Portamento note " & $MIDI_BYTE_1 & " in advanced mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) case 64 to 100 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $mediumLegatoDelay) * 1000) $lastDelay := $mediumLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"Medium legato note " & $MIDI_BYTE_1 & " in advanced mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) case 101 to 127 if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"Fast legato note " & $MIDI_BYTE_1 & " in advanced mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) end select if($autoRebow = 1) set_midi($inputChannel,$MIDI_COMMAND_CC,64,127) end if else if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $firstLegatoDelay) * 1000) $lastDelay := $firstLegatoDelay else $lastDelay := 0 end if set_text($statusLabel,"First legato note " & $MIDI_BYTE_1 & " in advanced mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) end if if($autoRebow = 1) set_midi($inputChannel,$MIDI_COMMAND_CC,64,127) end if set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) $legatoNoteCount := $legatoNoteCount + 1 $legatoNotePitch := $MIDI_BYTE_1 else if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) wait (($slowLegatoDelay - $fastLegatoDelay) * 1000) $lastDelay := $fastLegatoDelay else $lastDelay := 0 end if $legatoNoteCount := 0 set_text($statusLabel,"Sustain note " & $MIDI_BYTE_1 & " in standard mode, with delay of " & $lastDelay & ", legato phrase length: " & $legatoNoteCount) set_midi($inputChannel,$MIDI_COMMAND_NOTE_ON,$MIDI_BYTE_1,$MIDI_BYTE_2) end if end select end if call UpdateDebug end if {MIDI NOTE OFF} if ($MIDI_COMMAND = $MIDI_COMMAND_NOTE_OFF and $MIDI_CHANNEL = $inputChannel) {Check we're not playing a keyswitch} if(not in_range($EVENT_NOTE,$keyswitchLow,$keyswitchHigh)) {This note is not a keyswitch, drop it} ignore_midi if (($lastDelayCCValue > 64 and $delayMode = 0) or ($delayMode = 1)) if($legatoMode = 1) {We add 32 mu to this in order to force legato overlaps on notes} wait (($slowLegatoDelay - $lastDelay + 32) * 1000) $legatoNoteCount := $legatoNoteCount - 1 if ($legatoNoteCount < 0) $legatoNoteCount := 0 end if {message("Delayed Legato Note Off. Delay: " & $lastDelay & " Sequence: " & $legatoNoteCount)} else {If we are not in legato mode, we should set the legato phrase length counter to 0 before delaying the note off} {This is to deal with instances of swapping to a legato phrase immediately after the end of a non legato note} {In this case, the legatoNoteCount would decrement after the first legato note on, resulting in first note legato only} $legatoNoteCount := 0 if ($noteMode = 1) wait (($slowLegatoDelay - $shortsDelay - 2 ) * 1000) else wait (($slowLegatoDelay - $lastDelay - 2) * 1000) end if {message("Delayed Note Off. Delay: " & $lastDelay & " Sequence: " & $legatoNoteCount)} end if else {message("Note Off. Delay: " & $lastDelay & " Sequen ce: " & $legatoNoteCount)} end if if($autoRebow = 1) if ($legatoNoteCount = 0) set_midi($inputChannel,$MIDI_COMMAND_CC,64,0) end if end if set_midi($inputChannel,$MIDI_COMMAND_NOTE_OFF,$MIDI_BYTE_1,$MIDI_BYTE_2) end if call UpdateDebug end if end on